<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="${web_domain}/resources/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="${web_domain}/resources/layuiadmin/style/admin.css" media="all">
<script type="text/javascript" src="${web_domain}/resources/plugins/jquery.js"></script>
<script type="text/javascript" src="${web_domain}/resources/plugins/jquery.form.js"></script>
<script src="${web_domain}/resources/layuiadmin/layui/layui.js"></script>
<script defer type="text/javascript" src="${web_domain}/resources/js/feijin_http.js"></script>

<script>
    layui.config({
        base: '${web_domain}/resources/layuiadmin/'
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'contlist', 'table','form','laydate','layedit'], function () {
        var table = layui.table, form = layui.form, laydate = layui.laydate;
    });

    $(function () {
        $(document).on("click", ".preview", function () {
            var num = 1;
            var src = this.src;

            var width = 0;
            var height = 0;
            var img;
            var deg = 0;

            layer.open({
                type: 1,
                title: "图片预览",
                maxmin: true,
                area: ["90%", "90%"],
                content: '<table class="img-preview-table"><tr><td style="text-align: center;"><img id="current-preview" src="' + this.src + '"></td></tr></table>',
                btn: ["旋转", "下载", "关闭"],
                success: function (layero, index) {

                    var content = $(layero).find(".layui-layer-content");
                    var table = $(layero).find(".img-preview-table");
                    img = $(layero).find("#current-preview")

                    width = content.width() - 20;
                    height = content.height() - 20;

                    table.css({"width": width, "height": height});
                    img.css({"max-width": width, "max-height": height});

                },
                full: function (layero) {
                    var content = $(layero).find(".layui-layer-content");
                    var table = $(layero).find(".img-preview-table");
                    img = $(layero).find("#current-preview");

                    width = content.width();
                    height = content.height()

                    table.css({"width": width, "height": height});
                    img.css({"max-width": width, "max-height": height});
                },
                restore: function (layero) {
                    var content = $(layero).find(".layui-layer-content");
                    var table = $(layero).find(".img-preview-table");
                    img = $(layero).find("#current-preview")

                    width = content.width();
                    height = content.height()

                    table.css({"width": width, "height": height});
                    img.css({"max-width": width, "max-height": height});
                },
                yes: function (index, layero) {
                    deg = 90 * num;
                    if (num % 2 === 1) {
                        img.css({"max-width": height, "max-height": width, "transform": "rotate(" + deg + "deg)"});
                    } else {
                        img.css({"max-width": width, "max-height": height, "transform": "rotate(" + deg + "deg)"});
                    }

                    num++;
                    return false;
                },
                btn2: function (index, layero) {
                    //下载
                    window.open("${web_domain}/image/download?url=" + src);
                }
            })
        });
    });
</script>